﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using RED_NET_Core.BLL;

namespace RED_NET.MasterPage
{
    public partial class CollegeIndex : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        public void PopulateNode(Object sender, TreeNodeEventArgs e)
        {
            LoginBLL _login = new LoginBLL();
            DataTable _dt = _login.GetCollegeUser();

            foreach (DataRow _dr in _dt.Rows)
            {
                TreeNode NewNode = new TreeNode(_dr["_NickName"].ToString());
                DataTable _dt2 = _login.GetClassUser(Int32.Parse(_dr["_College"].ToString()));


                // Set additional properties for the node.
                NewNode.SelectAction = TreeNodeSelectAction.Expand;
                TreeNode tNewNode = new TreeNode("学院主页");
                tNewNode.NavigateUrl = "~/ContentPage/User/MainPage.aspx?VISIT_ID=" + _dr["_UId"].ToString();
                tNewNode.SelectAction = TreeNodeSelectAction.Select;
                NewNode.ChildNodes.Add(tNewNode);
                foreach (DataRow _dr2 in _dt2.Rows)
                {

                    NewNode.PopulateOnDemand = true;
                    TreeNode _newNode2 = new TreeNode(_dr2["_NickName"].ToString());
                    _newNode2.PopulateOnDemand = false;
                    _newNode2.SelectAction = TreeNodeSelectAction.Select;
                    _newNode2.NavigateUrl = "~/ContentPage/User/MainPage.aspx?VISIT_ID=" + _dr2["_UId"].ToString();
                    NewNode.ChildNodes.Add(_newNode2);

                }
                // Add the new node to the ChildNodes collection of the parent node.
                e.Node.ChildNodes.Add(NewNode);

            }
            e.Node.CollapseAll();
        }
        protected void TreeView_Navigetion_Selected(object sender, EventArgs e)
        {

        }
    }
}
